package cn.csc.module.search.controller.admin.sku;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.module.search.controller.admin.sku.vo.SkuRespVO;
import cn.csc.module.search.convert.SkuConvert;
import cn.csc.module.search.dal.dataobject.sku.SkuDO;
import cn.csc.module.search.service.sku.SkuService;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigInteger;
import java.util.List;

/**
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/19 15:55
 */
@Api(tags = "管理后台 - sku信息")
@RestController
@RequestMapping("/search/sku")
public class SkuController {

    @Autowired
    private SkuService skuService;

    @GetMapping("/getBySpuId")
    @Operation(summary = "根据Spu_id获取sku信息")
    public CommonResult<List<SkuRespVO>> searchWithSkuAndStockOfPage(@RequestParam BigInteger spuId){
        List<SkuDO> skuDOS = skuService.findBySpuId(spuId);
        List<SkuRespVO> respVOS = SkuConvert.INSTANCE.convertList1(skuDOS);
        return CommonResult.success(respVOS);
    }



}
